% construct diffusion and random force part
function rest = randomtest(t,y,para,casenum)

load('alphas'); load('msval');
num=para(1);alphaK=para(2);
dt1=0.5/num; 
t2index=floor((t+0.5*dt1)/dt1)+1;
switch casenum
    case 1
        alpharow=size(alphas,1);
        row=alpharow;
        myfun=para(3);
        if row >=2
            rest(row)=0;
        end
        rest(1)=0;
        rest(2:alphaK+1)=myfun(t)*msval(t2index,1:alphaK);
    case 5
        alpharow=size(alphas,1);
        row=alpharow;
        if row >=2
            rest(row)=0;
        end
        rest(1)=sum(sig(t2index,2:alphaK+1).*wsval(t2index,1:alphaK),2);
        for ii=2:alphaK+1
            rest(ii)=sig(t2index,1).*wsval(t2index,ii-1);
        end
        rest(alphaK+2:2*alphaK+1)=sqrt(2)*sig(t2index,2:alphaK+1).*wsval(t2index,1:alphaK);
        begins=2*alphaK+2; ends=begins+alphaK*(alphaK-1)/2-1;
        for ii=begins:ends
            myk=find(alphas(ii,:)==1);
            rest(ii)=wsval(t2index,myk(1)).*sig(t2index,myk(2)+1)+wsval(t2index,myk(2)).*sig(t2index,myk(1)+1);
        end
end
rest=rest';



